package J20250330_real;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 王圆豪
 * Date: 2025-04-02
 * Time: 18:46
 */
import java.util.*;
// 1:无需package
// 2: 类名必须Main, 不可修改

public class Main3 {
    static int count = 10;
    public static void main(String[] args) {
        long num = 127;
        while(true){
            if(func(num)){
                count++;
            }
            if(count == 2023) break;
            num++;
        }
        System.out.println(num);
    }

    static boolean func(long num){
        if(func2(num,2)&&func2(num,8)&&func2(num,10)&&func2(num,16)) return true;
        return false;
    }

    static boolean func2(long num,int cur){
        long k = num;
        List<Long> l = new ArrayList<>();
        while(num!=0){
            long tmp = num % cur;
            num /= cur;
            l.add(tmp);
        }
        Collections.reverse(l);
        long ret = 0;
        boolean flag = false;
        for(long a : l){
            if(a != 0) flag = true;
            if(flag) ret += a;
        }
        return k%ret==0;
    }
}